set(LIB_NAME osgLua)

set(HEADER_PATH ${osgLua_SOURCE_DIR}/include/${LIB_NAME})

file(GLOB LIB_HEADERS "${osgLua_SOURCE_DIR}/src/osgLua/*.h")
set(LIB_HEADERS ${LIB_HEADERS} ${HEADER_PATH}/Script)

file(GLOB LIB_SOURCES "${osgLua_SOURCE_DIR}/src/osgLua/*.cpp")

if(OSGLUA_USE_INTERNAL_LUA)
	file(GLOB LUA_SOURCES "${osgLua_SOURCE_DIR}/src/lua-5.1.2/src/*.c")
	list(REMOVE_ITEM LUA_SOURCES
		"${osgLua_SOURCE_DIR}/src/lua-5.1.2/src/lua.c" 
		"${osgLua_SOURCE_DIR}/src/lua-5.1.2/src/luac.c"
	)
	set(LIB_SOURCES ${LIB_SOURCES} ${LUA_SOURCES})
endif(OSGLUA_USE_INTERNAL_LUA)

include_directories(
	${osgLua_SOURCE_DIR}/include
	${OSG_INCLUDE_DIR}
	${LUA_INCLUDE_DIR}
)

add_library(${LIB_NAME} SHARED 
	${LIB_HEADERS}
	${LIB_SOURCES}
)

target_link_libraries(${LIB_NAME}
	${LUA_LIBRARY}
	${OSG_LIBRARY}
	osgIntrospection
)

ADD_DEFINITIONS(-DOSGLUA_LIBRARY)

IF(UNIX)
	SET_TARGET_PROPERTIES ( osgLua PROPERTIES LINK_FLAGS "-Wl,-E")
ENDIF(UNIX)


